<template>
  <div id="changedialog">
    <commonformdialog
      :isshowDialogs="isshowDialog"
      :dialogTitle="dialogTitle"
      @closetextDialog="closetextDialog"
      @confirmbtn="confirmbtn"
    >
      <div class="innerLoding">
        <el-row>
          <el-form
            :model="formData"
            :rules="rules"
            ref="ruleForm"
            label-width="80px"
            size="small"
          >
            <el-row>
              <el-col :span="24">
                <el-form-item label="移交人:" prop="title">
                  <el-select
                    v-model="formData.approvalUser"
                    placeholder="请选择移交人"
                    style="width: 95%"
                    clearable
                  >
                    <el-option
                      :label="item.title"
                      :value="item.id"
                      v-for="(item, index) in updateUserOptions"
                      :key="index"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-row>
      </div>
    </commonformdialog>
  </div>
</template>

<script type="text/javascript">
//引入弹窗
import commonformdialog from "@/components/commondialog/commondialog";
import { examineTransfer} from "@/api/institutional";

export default {
  data() {
    return {
      formData: {
        approvalUser: "",
      },
      rules: {
        approvalUser: [{ required: true, message: "请选择移交人", trigger: "blur" }],
      },
    };
  },
  props: {
    //是否显示弹窗
    isshowDialog: {
      type: Boolean,
      default: false,
      required: true,
    },
    //表单的名字
    dialogTitle: {
      type: String,
      default: "",
      required: true,
    },
    //是编辑还是新增
    formType: {
      type: Number,
      default: 0,
    },
    dialogdata: {
      type: Object,
    },
    updateUserOptions:{
        type: Array,
    }
  },
  components: {
    commonformdialog,
  },
  methods: {
    closetextDialog() {
      this.$emit("closedialog");
    },
    confirmbtn() {
      this.$refs["ruleForm"].validate(async (valid) => {
        if (!valid) return;
        let params = this.formData;
        let data = await examineTransfer(params);
        if (data.code == "0000") {
          this.$message({
            type: "success",
            message: data.msg,
          });
          this.$emit("confirm");
        }
      });
    },
  },
  watch: {
    isshowDialog: function (val) {
      if (!val) {
        this.$refs["ruleForm"].resetFields();
      }
    },
    dialogdata: function (val) {
      this.$nextTick(() => {
        this.formData.id = val.id;
        this.formData.type = 8;
        this.formData.approvalUser = val.approval_user;
      });
    },
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
::v-deep {
  #InputSearch {
    display: none !important;
  }
  .grid-emojis {
    grid-template-columns: repeat(10, 10%) !important;
  }
  .small {
    position: absolute;
    z-index: 9;
    left: -45px;
    top: 30px;
  }
  #ue1 {
    line-height: normal;
  }
}
</style>
